From: Keir Fraser Date: Fri, 20 Mar 2009 12:09:20 +0000 (+0000) Subject: xend: specify the slot for pass-through devices X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~13992^2~8 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=5534b7d9866f754c269ba33c7602d93cc4ff9ecd;p=xen.git xend: specify the slot for pass-through devices Currently a slot may be specified for a hot-plug device, but not for a pass-through device that is inserted at boot time. This patch adds support for the latter. The syntax is: BUS:DEV.FUNC[@VSLOT] e.g: 0000:00:1d:0@7 This may be important as recent changes that allow any free PCI slot to be used for pass-through (and hotplug) may case pass-through devices to be assigned in different locations to before. Amongst other things, specifying the slot will allow users to move them back, if there is a need. Signed-off-by: Simon Horman --- diff --git a/tools/python/xen/xend/server/pciif.py b/tools/python/xen/xend/server/pciif.py index 2344de4041..e6ba4bc695 100644 --- a/tools/python/xen/xend/server/pciif.py +++ b/tools/python/xen/xend/server/pciif.py @@ -75,6 +75,7 @@ class PciController(DevController): bus = parse_hex(pci_config.get('bus', 0)) slot = parse_hex(pci_config.get('slot', 0)) func = parse_hex(pci_config.get('func', 0)) + vslot = parse_hex(pci_config.get('vslot', 0)) opts = pci_config.get('opts', '') if len(opts) > 0: diff --git a/tools/python/xen/xm/create.py b/tools/python/xen/xm/create.py index b0de5c5811..8ad0fe6dfd 100644 --- a/tools/python/xen/xm/create.py +++ b/tools/python/xen/xm/create.py @@ -1,4 +1,4 @@ -#============================================================================ +#============================================================================UTO # This library is free software; you can redistribute it and/or # modify it under the terms of version 2.1 of the GNU Lesser General Public # License as published by the Free Software Foundation. @@ -32,6 +32,7 @@ from xen.xend import PrettyPrint as SXPPrettyPrint from xen.xend import osdep import xen.xend.XendClient from xen.xend.XendBootloader import bootloader +from xen.xend.XendConstants import * from xen.xend.server.DevConstants import xenbusState from xen.util import blkif from xen.util import vscsi_util @@ -322,10 +323,12 @@ gopts.var('disk', val='phy:DEV,VDEV,MODE[,DOM]', backend driver domain to use for the disk. The option may be repeated to add more than one disk.""") -gopts.var('pci', val='BUS:DEV.FUNC[,msitranslate=0|1][,power_mgmt=0|1]', +gopts.var('pci', val='BUS:DEV.FUNC[@VSLOT][,msitranslate=0|1][,power_mgmt=0|1]', fn=append_value, default=[], use="""Add a PCI device to a domain, using given params (in hex). For example 'pci=c0:02.1'. + If VSLOT is supplied the device will be inserted into that + virtual slot in the guest, else a free slot is selected. If msitranslate is set, MSI-INTx translation is enabled if possible. Guest that doesn't support MSI will get IO-APIC type IRQs translated from physical MSI, HVM only. Default is 1. @@ -696,7 +699,7 @@ def configure_pci(config_devs, vals): """Create the config for pci devices. """ config_pci = [] - for (domain, bus, slot, func, opts) in vals.pci: + for (domain, bus, slot, func, vslot, opts) in vals.pci: config_pci_opts = [] d = comma_sep_kv_to_dict(opts) @@ -707,7 +710,7 @@ def configure_pci(config_devs, vals): config_pci_opts.append([k, d[k]]) config_pci_bdf = ['dev', ['domain', domain], ['bus', bus], \ - ['slot', slot], ['func', func]] + ['slot', slot], ['func', func], ['vslot', vslot]] map(f, d.keys()) if len(config_pci_opts)>0: config_pci_bdf.append(['opts', config_pci_opts]) @@ -1054,16 +1057,21 @@ def preprocess_pci(vals): r"(?P[0-9a-fA-F]{1,2})[:,]" + \ r"(?P[0-9a-fA-F]{1,2})[.,]" + \ r"(?P[0-7])" + \ - r"(,(?P.*))?$", pci_dev_str) + r"(@(?P[0-9a-fA-F]))?" + \ + r"(,(?P.*))?$", \ + pci_dev_str) if pci_match!=None: pci_dev_info = pci_match.groupdict('') if pci_dev_info['domain']=='': pci_dev_info['domain']='0' + if pci_dev_info['vslot']=='': + pci_dev_info['vslot']="%02x" % AUTO_PHP_SLOT try: pci.append( ('0x'+pci_dev_info['domain'], \ '0x'+pci_dev_info['bus'], \ '0x'+pci_dev_info['slot'], \ '0x'+pci_dev_info['func'], \ + '0x'+pci_dev_info['vslot'], \ pci_dev_info['opts'])) except IndexError: err('Error in PCI slot syntax "%s"'%(pci_dev_str))